﻿CREATE PROCEDURE [dbo].[ETL_SP_GetDtTableColumnAndMapping]
	@dtTableId uniqueidentifier,
	@DtSourceId uniqueidentifier
AS
	SELECT DTC.*,
		DSC.Name as MappingColumnName,
		DSC.DataType as MappingColumnType,
		DSC.Id as MappingColumnId
	FROM ETL_DtTableColumn as DTC
		LEFT join ETL_DtSourceColumnMapping as DSCM on DSCM.DtTableColumnId = DTC.Id
			and DSCM.DtSourceId=@DtSourceId
		LEFT join ETL_DtSourceColumn as DSC on DSC.Id = DSCM.DtSourceColumnId
			and DSC.DtSourceId=@DtSourceId
	where
		DTC.DtTableId = @dtTableId
RETURN 0
